<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * View file: group_form
 *
 * @author luubk
 * @since 10-06-2012 - 14:02:19
 */
?>
<div id="form_result"></div>
<article class="module width_full">
    <form method="POST" id="form" 
          action="<?php echo $id ? site_url("user/group_form/$id") : site_url("user/group_form") ?>">
        <header><h3><?php echo $title ?></h3></header>
        <div class="module_content">

            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Tên nhóm</label>
                <input type="text" style="width:92%;" value="<?php echo isset($item['ug_name']) ? $item['ug_name'] : '' ?>"
                       name="ug_name" required="required">
            </fieldset>

            <fieldset style="width:48%; float:right;padding: .3em;display: block">
                <label>Quyền hạn</label>
                <div class="clear"></div>
                <?php foreach ($list_permission as $cls => $data): ?>                    
                    <h3><?php echo $data['name'] ?></h3>                    
                    <?php foreach ($data['method'] as $func => $f_data): ?>
                        <div style="width: 38%;float:left; margin-right: 3%;">
                            <input type="checkbox" name="ug_role[]" 
                            <?php
                            if (isset($item['ug_role']))
                                if (in_array("$cls:$func", unserialize($item['ug_role'])))
                                    echo 'checked="checked"';
                            ?>                                   
                                   value="<?php echo "$cls:$func" ?>" />
                                   <?php echo $f_data['name'] ?>
                        </div>                        
                    <?php endforeach; ?>                    
                    <div class="clear"></div>
                <?php endforeach; ?>
            </fieldset>

            <fieldset style="width:48%; float:left; margin-right: 3%;">
                <label>Mô tả</label>
                <textarea rows="5" style="width:92%;" 
                          name="ug_desc"><?php echo isset($item['ug_desc']) ? $item['ug_desc'] : '' ?></textarea>
            </fieldset>

            <div class="clear"></div>
        </div>
        <footer>
            <div class="submit_link">
                <span class="loading">&nbsp;</span>
                <select name="ug_status">
                    <option value="1" <?php echo (isset($item['ug_status']) && $item['ug_status'] == 1) ? 'selected="selected"' : '' ?>>Kích hoạt</option>
                    <option value="0" <?php echo (isset($item['ug_status']) && $item['ug_status'] == 0) ? 'selected="selected"' : '' ?>>Vô hiệu hóa</option>
                </select>
                <input type="submit" value="Lưu lại" class="alt_btn">
                <input type="reset" value="Nhập lại">                
            </div>
        </footer>
    </form>
</article><!-- end of post new article -->
